﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sherwood.Security;
using Sherwood.SignOn.Server.Models.Services;

namespace Sherwood.SignOn.Server.Models.Repositories.Sql
{
    public partial class UserSession : IUserSession
    {

        IUserAccount IUserSession.UserAccount
        {
            get
            {
                return Data.UserAccounts.GetUserAccount(this.UserAccountId.GetValueOrDefault());
            }
        }

        public IEnumerable<IUserSessionClientRecord> ClientRecords
        {
            get
            {
                SqlRepositoryDataContext db = new SqlRepositoryDataContext();
                List<IUserSessionClientRecord> clientRecords = new List<IUserSessionClientRecord>((from r in db.UserSessionClientRecords where r.UserSessionId.GetValueOrDefault() == this.Id select r).ToArray());
                db.Dispose();
                return clientRecords;
            }
        }
    }
}
